<?php /*a:2:{s:64:"H:\xampp\htdocs\www\lqb\application\login\view\sign\addSign.html";i:1563842112;s:63:"H:\xampp\htdocs\www\lqb\application\login\view\public\head.html";i:1563842112;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台管理系统 - Layui</title>
    <script type="text/javascript" src="/static/admin/layui/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="/static/admin/layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css" />
    <script type="text/javascript" src="/static/js/md5/md5.js"></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a id="updateAll" href="javascript:updateStatua()">更新贷款状态</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    <span id="username" class="username"></span>
                </a>
                <!--<dl class="layui-nav-child">-->
                    <!--<dd><a href="">基本资料</a></dd>-->
                    <!--<dd><a href="">安全设置</a></dd>-->
                <!--</dl>-->
            </li>
            <li class="layui-nav-item"><a href="javascript:showTime()">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-shrink=""  lay-filter="test">

                <li class="layui-nav-item <?php if((app('request')->path() == 'login/Sign/addSign') OR (app('request')->path() == 'login/Sign/allSign')): ?>layui-nav-itemed<?php endif; ?>">
                    <a class="" href="javascript:;">渠道管理</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'login/Sign/addSign'): ?>layui-this<?php endif; ?>"><a href="/login/Sign/addSign">添加渠道</a></dd>
                        <dd class="<?php if(app('request')->path() == 'login/Sign/allSign'): ?>layui-this<?php endif; ?>"><a href="/login/Sign/allSign">管理渠道</a></dd>
                        <!--<dd><a href="/admin/Category/index">推广等级</a></dd>-->
                        <!--<dd><a href="/admin/Grade/fetch_add_grade">添加等级</a></dd>-->
                    </dl>
                </li>

                <li class="layui-nav-item <?php if((app('request')->path() == 'login/Show/index') OR (app('request')->path() == 'login/Registered/index')): ?>layui-nav-itemed<?php endif; ?>">
                    <a class="" href="javascript:;">推广渠道</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'login/Show/index'): ?>layui-this<?php endif; ?>"><a href="/login/Show/index">进来流量</a></dd>
                        <dd class="<?php if(app('request')->path() == 'login/Registered/index'): ?>layui-this<?php endif; ?>"><a href="/login/Registered/index">注册量</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item <?php if((app('request')->path() == 'login/Statistics/index')): ?>layui-nav-itemed<?php endif; ?>">
                    <a class="" href="javascript:;">统计</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'login/Show/Statistics'): ?>layui-this<?php endif; ?>"><a href="/login/Statistics/index">流量统计</a></dd>
                    </dl>
                </li>

            </ul>
        </div>
    </div>

    <div id="main" class="layui-body">
        <!-- 内容主体区域 -->
       <blockquote class="layui-elem-quote" style="margin: 15px"><!-- 内容变量--></blockquote>
        

<!--<form class="layui-form" action="/admin/Banner/addBannerPic" method="POST">-->
<form class="layui-form" lay-filter="addSign">

    <div class="layui-form-item">
        <label class="layui-form-label " style="width: 100px">渠道名称</label>
        <div class="layui-input-inline">
            <input type="hidden" name="id" value="<?php echo htmlentities((isset($info['sign_id']) && ($info['sign_id'] !== '')?$info['sign_id']:'')); ?>">
            <input type="text" name="channel" placeholder="请输入渠道名称" id="channel" class="layui-input" lay-verify="required" value="<?php echo htmlentities((isset($info['channel']) && ($info['channel'] !== '')?$info['channel']:'')); ?>" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label " style="width: 100px">推广标识</label>
        <div class="layui-input-inline">
            <input type="text" name="sign" placeholder="" id="sign" class="layui-input" lay-verify="required" value="<?php echo htmlentities((isset($info['sign']) && ($info['sign'] !== '')?$info['sign']:'')); ?>" <?php if($info['sign_id'] !== ''): ?>disabled<?php endif; ?>>
        </div>
        <div class="layui-input-inline">
            <a class="layui-btn layui-btn-warm" onclick="javascript:randomPassword(5, 'sign')">随机生成</a>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label " style="width: 100px">密码</label>
        <div class="layui-input-inline">
            <input type="text" name="pwd" placeholder="" id="pwd" class="layui-input" lay-verify="required" value="<?php echo htmlentities((isset($info['pwd']) && ($info['pwd'] !== '')?$info['pwd']:'')); ?>">
        </div>
        <div class="layui-input-inline">
            <a class="layui-btn layui-btn-warm" onclick="javascript:randomPassword(8, 'pwd')">随机生成</a>
        </div>
    </div>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label " style="width: 100px">流量隐藏倍数</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="pop_num" placeholder="请输入1-10整数" id="pop_num" class="layui-input" >-->
<!--        </div>-->
<!--    </div>-->

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label " style="width: 100px">注册隐藏倍数</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="reg_num" placeholder="请输入1-10整数" id="reg_num" class="layui-input" >-->
<!--        </div>-->
<!--    </div>-->

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">域名</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="checkbox" name="like[write]" title="单期">-->
<!--            <input type="checkbox" name="like[read]" title="分期">-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label"  style="width: 100px">状态</label>
        <div class="layui-input-block">
            <input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" lay-filter="switchTest" <?php if($info['status'] == 1): ?>checked <?php endif; ?>>
            <div class="layui-unselect layui-form-switch" lay-skin="_switch">
                <em>OFF</em><i></i>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button lay-submit class="layui-btn"  lay-filter="buttonSign">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script type="text/javascript">


    layui.use(['form','layedit'], function(){
        var form = layui.form
        var layer = layui.layer;
        // var $= layui.jquery;
        var token = layui.data('cache').token;

        form.on('submit(buttonSign)', function(data){
            console.log(data)
            $.ajax({
                url:"/login/Sign/signApi",
                type:"post",
                headers:{"token":token},
                data:{"data":data.field},
                dataType:"json",
                success:function (res) {
                    layer.msg(res.msg)
                    setTimeout(function (){
                        window.location.href = "/login/Sign/allSign"
                    }, 3000)

                },
                error:function (error) {
                    console.log(error.msg)
                }
            })
            return false;
        });
    });

    // 随机生成密码
    function randomPassword(size, idNum)
    {
        var seed = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z',
            'a','b','c','d','e','f','g','h','i','j','k','m','n','p','Q','r','s','t','u','v','w','x','y','z',
            '2','3','4','5','6','7','8','9'
        );//数组
        seedlength = seed.length;//数组长度
        var createPassword = '';
        for (i=0;i<size;i++) {
            j = Math.floor(Math.random()*seedlength);
            createPassword += seed[j];
        }
        $("#"+idNum).val(createPassword);
    }

</script>


    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 感谢
    </div>
</div>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use(['element','form'], function(){
        var form = layui.form;
        // 获取本地缓存中的token
        var tokenValue = layui.data('cache');
        if(tokenValue.token !== 'undefined'){
            $.ajax({
                url:"/api/v1.Token/verifyToken",
                headers:{"token":tokenValue.token},
                type:"post",
                dataType:"json",
                success:function(res){
                    // 200则token不失效
                    if(res.code == 200){
                        var token = layui.data('cache')
                        $.ajax({
                            url:"/login/Show/getUserData",
                            type:"post",
                            headers:{"token":token.token},
                            dataType:"json",
                            success:function (res) {
                                $('#title').html(res.name + '推广详情页面')
                                $('#username').html(res.name)
                                data = res.sign
                                for(var key in data){
                                    $("#signData").append("<option value='" + data[key] + "'>" + data[key] + "</option>");
                                }
                                form.render('select');
                            }
                        })
                    }
                    // 404则token失效
                    if(res.code == 404 || res.code == 401){
                        window.location.href = "/login/Index/Timeout"
                    }
                },
                error:function(error){
                    console.log(error.responseJSON.code)
                    if(error.responseJSON.code == 401){
                        window.location.href = "/login/Index/Timeout"
                    }
                }
            })
        }

    });

    // 清除token退出
    function showTime(){
        layui.use(['element','form'], function(){
            var tokenValue = layui.data('cache');
            if(tokenValue.token){
                layui.data('cache', {
                    key: 'token'
                    ,remove: true
                });
            }
            // location.reload();
            window.location.href="/login/Index/out"
        })

    }
    function updateStatua() {
        var url = window.location.href;
        layui.use(['layer'], function(){
            var token = layui.data('cache').token;
            var layer = layui.layer;
            $.ajax({
                url:"/login/Registered/updateAllStatus",
                type:"post",
                headers:{"token":token},
                dataType:"json",
                success:function (res) {
                    if(res.code == 200){
                        layer.msg('更新成功,今天可用次数为'+ res.num + ',即将刷新页面');
                        setTimeout(function () {
                            window.location.href = url
                        }, 3000)
                    }
                    if(res.code == 400){
                        layer.msg('更新失败, 今天的可用次数为0');
                    }

                },
                error:function (error) {
                    layer.msg('更新成功');
                }
            })
        })
    }

    var tip_index = 0;
    $(document).on('mouseenter', '#updateAll', function(){
        tip_index = layer.tips('更新贷款状态，每天只能手动更新八次，后台每两个钟会自动更新一次，不会消耗手动更新次数', '#updateAll', {time: 0});
    }).on('mouseleave', '#updateAll', function(){
        layer.close(tip_index);
    });
</script>
</body>
</html>